package com.wx.api.service;


import com.wx.api.pay.IPayService;
import com.wx.model.dto.PayParameter;
import com.wx.model.dto.PrePayDto;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 支付服务
 *
 * @author liaogui
 * @date 2023/12/09
 */
@Service("payService")
public class PayService {
    @Resource
    private List<IPayService> payServiceList;

    /**
     * 发起支付
     * 适配模式
     * @return {@link PayParameter }
     * @author liaogui
     */
    public PrePayDto createPay(PayParameter payParameter) throws Exception {
        PrePayDto prePayDto = new PrePayDto();
        for (IPayService iPayService : payServiceList) {
            if (iPayService.support(payParameter.getType())) {
                iPayService.createPrepayOrder(payParameter);
            }
        }
        return prePayDto;
    }
}
